'\" te
.\" Copyright (c) 2009, Sun Microsystems, Inc.  All Rights Reserved.
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License. You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.
.\"  See the License for the specific language governing permissions and limitations under the License. When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with
.\" the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
.TH PSET_BIND 2 "Mar 13, 2009"
.SH NAME
pset_bind \- bind LWPs to a set of processors
.SH SYNOPSIS
.LP
.nf
#include <sys/pset.h>

\fBint\fR \fBpset_bind\fR(\fBpsetid_t\fR \fIpset\fR, \fBidtype_t\fR \fIidtype\fR, \fBid_t\fR \fIid\fR, \fBpsetid_t *\fR\fIopset\fR);
.fi

.SH DESCRIPTION
.LP
The \fBpset_bind()\fR function binds the \fBLWP\fR or set of \fBLWPs\fR
specified by \fIidtype\fR and \fIid\fR to the processor set specified by
\fIpset\fR. If \fIopset\fR is not \fINULL\fR, \fBpset_bind()\fR sets the
\fBpsetid_t\fR variable pointed to by \fIopset\fR to the previous processor set
binding of one of the specified \fBLWP\fR, or to \fBPS_NONE\fR if the selected
\fBLWP\fR was not bound.
.sp
.LP
If \fIidtype\fR is \fBP_PID\fR, the binding affects all \fBLWP\fRs of the
process with process \fBID\fR (PID) \fIid\fR.
.sp
.LP
If \fIidtype\fR is \fBP_LWPID\fR, the binding affects the \fBLWP\fR of the
current process with \fBLWP ID\fR \fIid\fR.
.sp
.LP
If \fIidtype\fR is \fBP_TASKID\fR, the binding affects all LWPs of all
processes with task ID \fIid\fR.
.sp
.LP
If \fIidtype\fR is \fBP_PROJID\fR, the binding affects all LWPs of all
processes with project ID \fIid\fR.
.sp
.LP
If \fIidtype\fR is \fBP_ZONEID\fR, the binding affects all LWPs of all
processes with zone ID \fIid\fR.
.sp
.LP
If \fIidtype\fR is \fBP_CTID\fR, the binding affects all LWPs of all processes
with process contract ID \fIid\fR.
.sp
.LP
If \fIid\fR is \fBP_MYID\fR, the specified LWP, process, task, process, zone,
or process contract is the current one.
.sp
.LP
If \fIpset\fR is \fBPS_NONE\fR, the processor set bindings of the specified
LWPs are cleared.
.sp
.LP
If \fIpset\fR is \fBPS_QUERY\fR, the processor set bindings are not changed.
.sp
.LP
If \fIpset\fR is \fBPS_MYID\fR, the specified LWPs are bound to the same
processor set as the caller. If the caller is not bound to a processor set, the
processor set bindings are cleared.
.sp
.LP
The {\fBPRIV_SYS_RES_CONFIG\fR} privilege must be asserted in the effective set
of the calling process or \fIpset\fR must be \fBPS_QUERY\fR.
.sp
.LP
LWPs that have been bound to a processor with \fBprocessor_bind\fR(2) may also
be bound to a processor set if the processor is part of the processor set. If
this occurs, the binding to the processor remains in effect. If the processor
binding is later removed, the processor set binding becomes effective.
.sp
.LP
Processor set bindings are inherited across \fBfork\fR(2) and \fBexec\fR(2).
.SH RETURN VALUES
.LP
Upon successful completion, 0 is returned. Otherwise, \(mi1 is returned and
\fBerrno\fR is set to indicate the error.
.SH ERRORS
.LP
The \fBpset_bind()\fR function will fail if:
.sp
.ne 2
.na
\fB\fBEBUSY\fR\fR
.ad
.RS 11n
One of the \fBLWP\fRs is bound to a processor, and the specified processor set
does not include that processor.
.RE

.sp
.ne 2
.na
\fB\fBEFAULT\fR\fR
.ad
.RS 11n
The location pointed to by \fIopset\fR was not \fINULL\fR and not writable by
the user.
.RE

.sp
.ne 2
.na
\fB\fBEINVAL\fR\fR
.ad
.RS 11n
An invalid processor set \fBID\fR was specified;  or \fIidtype\fR was not
\fBP_PID\fR, \fBP_LWPID\fR, \fBP_PROJID\fR, \fBP_TASKID\fR, \fBP_ZONEID\fR, or
\fBP_CTID\fR.
.RE

.sp
.ne 2
.na
\fB\fBENOTSUP\fR\fR
.ad
.RS 11n
The pools facility is active.  See \fBpooladm\fR(8) and
\fBpool_set_status\fR(3POOL) for information about enabling and disabling the
pools facility. Processes can be bound to pools using the \fBpoolbind\fR(8)
utility or the \fBpool_set_binding\fR(3POOL) function.
.sp
Binding a system process to a processor set is not supported.
.RE

.sp
.ne 2
.na
\fB\fBEPERM\fR\fR
.ad
.RS 11n
The {\fBPRIV_PROC_OWNER\fR} is not asserted in the effective set of the calling
process and either the real or effective user ID of the calling process does
not match the real or effective user \fBID\fR of one of the LWPs being bound,
or the processor set from which one or more of the LWPs are being unbound has
the \fBPSET_NOESCAPE\fR attribute set and {\fBPRIV_SYS_RES_CONFIG\fR) is not
asserted in the effective set of the calling process. See \fBpset_setattr\fR(2)
for more information about processor set attributes.
.RE

.sp
.ne 2
.na
\fB\fBESRCH\fR\fR
.ad
.RS 11n
No processes, \fBLWP\fRs, or tasks were found to match the criteria specified
by \fIidtype\fR and \fIid\fR.
.RE

.SH ATTRIBUTES
.LP
See \fBattributes\fR(7) for descriptions of the following attributes:
.sp

.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE	ATTRIBUTE VALUE
_
Interface Stability	Committed
_
MT-Level	Async-Signal-Safe
.TE

.SH SEE ALSO
.LP
.BR exec (2),
.BR fork (2),
.BR processor_bind (2),
.BR pset_create (2),
.BR pset_info (2),
.BR pset_setattr (2),
.BR pset_getloadavg (3C),
.BR pool_set_binding (3POOL),
.BR pool_set_status (3POOL),
.BR process (5),
.BR project (5),
.BR attributes (7),
.BR privileges (7),
.BR pbind (8),
.BR pooladm (8),
.BR poolbind (8),
.BR psrset (8)
